package com.example.webbackend.repository;

import com.example.webbackend.model.OfflineMessage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDateTime;
import java.util.List;

public interface OfflineMessageRepository extends JpaRepository<OfflineMessage, Long> {
    @Query("SELECT om FROM OfflineMessage om WHERE om.receiver = :receiver AND om.createTime >= :time")
    List<OfflineMessage> findValidMessagesByReceiver(String receiver, LocalDateTime time);
    
    void deleteByReceiver(String receiver);
}